<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<script src="<%=request.getContextPath()%>/ui/js/jquery.js"></script>
<%-- <script src="<%=request.getContextPath()%>/ui/js/paginate.js"></script> --%>
<%-- <script src="<%=request.getContextPath()%>/ui/js/customPaginate.js"></script> --%>
<script src="<%=request.getContextPath()%>/ui/js/jquery.dataTables.min.js"></script>
<script src="<%=request.getContextPath()%>/ui/js/customDataTables.js"></script>

<script type="text/javascript">
	function viewUser(userLoginId) {
		$('#userLoginId').val(userLoginId);
		$('#viewUserForm').attr('action', 'viewExistingUser.html');
		$('#viewUserForm').submit();
	}
	function addNewUser() {
		$('#viewUserForm').attr('action', 'viewNewUser.html');
		$('#viewUserForm').submit();
	}
	function viewUserDetails(userLoginId) {
		$('#userLoginId').val(userLoginId);
		$('#viewUserForm').attr('action', 'viewUserDetails.html');
		$('#viewUserForm').submit();
	}
</script>

<%@include file="/ui/jsp/includes/header.jspf"%>
<div class="hero-unit secondary_container">
	<div id="table-subject-header">
		View User List
		<hr>
	</div>
	<div class="row-fluid">
	<form method="POST" id="viewUserForm">
		<div class="addnew_button">
				<input type="button" value="Add New User" onclick="javascript:addNewUser()" class="btn btn-primary">
			</div>
		
		<div class="span10">
			
			<table id='dataTableList' class="table table-striped table-bordered">
				<thead>
					<tr>
						<c:if test="${roleId==1}">
							<th width="8%">Action</th>
						</c:if>
						<th>User Name</th>
						<th>User Role </th>
						<th>Faculty</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach var="userLogin" items="${usersList}">
						<tr class="paginationList">
							<c:if test="${roleId==1}">
								<td><a href="javascript:viewUser('${userLogin.userLoginId}')"><img src="<%=request.getContextPath()%>/ui/images/edit.gif" title="Edit" /></a> 
								<!-- <a href=""><img src="<%=request.getContextPath()%>/ui/images/delete.gif" title="Delete" /></a> -->
								</td>
							</c:if>
							<td>${userLogin.userName}</td>
							<td>${userLogin.userRole.roleName}</td>
							<td>${userLogin.faculty.firstName}&nbsp;${userLogin.faculty.lastName}</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
			
			<div class="pagination">
            </div>
			
		</div>
		<input type="hidden" id="userLoginId" name="userLoginId" value=""/>
		</form>
	</div>
</div>
<%@include file="/ui/jsp/includes/footer.jspf"%>
